/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __PQ_GameSceneManager_H__
#define __PQ_GameSceneManager_H__

#include "GameScene.h"

namespace PQClient
{
	/*Core class
	This class is used to manage the game scene change, update and so on...
	The game scene manager will be updated by main thread,and update
	the current active scene by the scene id set somewhere.
	*/
	class GameSceneManager
	{
	protected:
		GameSceneManager();
		
	public:
		~GameSceneManager();

		static GameSceneManager& getSingleton()
		{
			static GameSceneManager inst;
			return inst;
		}

		void init();

		void update(float deltaT);

		void setActiveSceneId(SceneId id);

		inline SceneId getActiveSceneId()
		{
			return _activeSceneId;
		}

		/*check to see whether the current scene is allowed to change
		*/
		bool isSceneTransitionAllowed(SceneId from,SceneId to);

		static bool legalSceneId(SceneId id);

	protected:
		//create and load scene
		void createScene(SceneId id);
	protected:
		//Scene transition table from row to col
		int transitionTable[Scene_Count][Scene_Count];

	protected:
		//scene management
		GameScene* _scenes[Scene_Count];
		SceneId _activeSceneId;
		SceneId _lastSceneId;

	};

}
#endif
